package demo2;

//牛客网:kotori和迷宫

import java.util.*;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int[] xx = {1,-1,0,0};
        int[] yy = {0,0,1,-1};
        String[] map = new String[n];
        for(int i = 0; i<n; i++) {
            map[i] = in.next();
        }

        int sx = 0, sy = 0;
        for(int i = 0; i<n; i++) {
            for(int j = 0; j<m; j++) {
                if(map[i].charAt(j) == 'k') {
                    sx = i;
                    sy = j;
                }
            }
        }

        boolean[][] st = new boolean[n][m];
        Queue<int[]> queue = new LinkedList<>();
        int count = 0;
        queue.add(new int[]{sx,sy});
        st[sx][sy] = true;

        int distance = Integer.MAX_VALUE;
        int step = 0;
        while(!queue.isEmpty()) {
            int size = queue.size();
            //System.out.println(step);
            for(int i = 0; i<size; i++) {
                int[] p = queue.poll();
                int x = p[0];
                int y = p[1];
                //System.out.println(x + " " + y + " " + map[x].charAt(y));
                if(map[x].charAt(y) == 'e') {
                    distance = Math.min(distance, step);
                    count++;
                    continue;
                }

                for(int j = 0; j<4; j++) {
                    int dx = x + xx[j];
                    int dy = y + yy[j];
                    if(dx >= 0 && dx < n && dy >= 0 && dy < m && map[dx].charAt(dy) != '*' && !st[dx][dy]) {
                        queue.add(new int[]{dx, dy});
                        st[dx][dy] = true;
                    }
                }
            }
             step++;
        }

        if(count == 0) {
            System.out.println(-1);
        }else {
            System.out.println(count + " " + distance);
        }
    }
}

/*

6 8
e.*.*e.*
.**.*.*e
..*k**..
***.*.e*
.**.*.**
*......e

*/